import { myEnv } from '@/myEnv';
import { mergeRequest } from '@/utils';

/** 修改头像 */
export const apiGetChageAvatar = async (formData: FormData) => {
    const response: MyResponse<any> = await sendRequest(formData);
    return response;
};

const sendRequest = async (formData: FormData) => {
    let response: MyResponse<any>;
    if (myEnv.IS_ON_LINE) {
        response = await mergeRequest({
            url: `user/upload-avatar`,
            method: 'POST',
            header: { 'content-type': 'multipart/form-data' },
            data: formData,
        });
    } else {
        response = {
            code: '200',
            message: 'ok',
        };
    }
    return response;
};
